<?php

namespace app\admin\controller;

use think\Controller;
use Util\SysDb;
use think\Db;
class Finance extends Controller
{
    public function financeunflowlist()
    {
        $type = trim(input('param.type'));
        $page = trim(input('param.pageNo'));
        $limit = trim(input('param.pageSize'));
        $tol = (intval($page) - 1) * $limit;
        if($type==""){
            $list = DB::name("ad_flow")->order("create_time desc")->limit($tol, $limit)->select();
            $this->db = new SysDb();
            $count = $this->db->table('ad_flow')->count();
            $data = array();
            array_push($data, $list);
            array_push($data, $count);
        }
        else{
        $list = DB::name("ad_flow")->order("create_time desc")->where(['type' =>  $type])->limit($tol, $limit)->select();
        $this->db = new SysDb();
        $count = $this->db->table('ad_flow')->where(['type' =>  $type])->count();
        $data = array();
        array_push($data, $list);
        array_push($data, $count);
        }
        exit(json_encode(['code' => 1, 'message' => 'succ', "result" => $data]));
    }

    public function financeunaddflow()
    {
        $remark = trim(input('param.remark'));
        $status = trim(input('param.status'));
        $money = trim(input('param.money'));
      $data['remark']=$remark;
      $data['status']=$status;
      $data['money']=$money;
      $data['type']=2;
        $this->db = new SysDb();
        $count = $this->db->table('ad_flow')->insert($data);
       
        if($count){
            exit(json_encode(['code' => 1, 'message' => 'succ', "result" =>"添加成功"]));
        }
        
    }
    public function financeunprofitlist()
    {
        $page = trim(input('param.pageNo'));
        $limit = trim(input('param.pageSize'));
        $tol = (intval($page) - 1) * $limit;
        $list = DB::name("ad_profit")->order("create_time desc")->limit($tol, $limit)->select();
        $this->db = new SysDb();
        $count = $this->db->table('ad_profit')->count();
        $data = array();
        array_push($data, $list);
        array_push($data, $count);
        
        exit(json_encode(['code' => 1, 'message' => 'succ', "result" => $data]));
    }
   
}

